//
//  HNSH_IntegralBillManagerHeader.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/3/1.
//

#import "HNSH_IntegralBillManagerHeader.h"
#import "HNSH_IntegralBillManager.h"

@interface HNSH_IntegralBillManagerHeader ()

/* bgImgV */
@property (nonatomic, strong) UIImageView *bgImgV;
/* icon */
@property (nonatomic, strong) UIImageView *icon;
/* titleLabel */
@property (nonatomic, strong) UILabel *titleLabel;
/* moneyLabel */
@property (nonatomic, strong) UILabel *moneyLabel;

@end

@implementation HNSH_IntegralBillManagerHeader

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        [self configUI];
    }
    return self;
}

- (void)setZjType:(NSInteger)zjType {
    _zjType = zjType;
    
}

- (void)configZjType:(NSInteger)zjType info:(NSDictionary *)info {
    _dic = info;
    _zjType = zjType;
    
    [self configUI];
    
    if (zjType == 1) {
        self.bgImgV.image = [UIImage imageNamed:@"jf_lszz_bg_green"];
        self.icon.image = [UIImage imageNamed:@"jf_lszz_icon_green"];
//        self.titleLabel.text = @"绿色能量";
//        self.moneyLabel.text = @"0.00";
    } else if (zjType == 7) {
        self.bgImgV.image = [UIImage imageNamed:@"jf_gwz_bg"];
        self.icon.image = [UIImage imageNamed:@"jf_gwz_icon_shopping"];
//        self.titleLabel.text = @"购物值";
//        self.moneyLabel.text = @"0.00";
    } else if (zjType == 6) {
        self.bgImgV.image = [UIImage imageNamed:@"jf_gxz_bg"];
        self.icon.image = [UIImage imageNamed:@"jf_gxz_icon_gongxian"];
//        self.titleLabel.text = @"贡献值";
//        self.moneyLabel.text = @"0.00";
    } else if (zjType == 4) {
        self.bgImgV.image = [UIImage imageNamed:@"jf_gwz_bg"];
        self.icon.image = [UIImage imageNamed:@"jf_hyd_icon_huoyue"];
    }
    self.titleLabel.text = [NSString stringWithFormat:@"%@", info[@"main_label"]];
    self.moneyLabel.text = [NSString stringWithFormat:@"%.2f", [info[@"main_value"] doubleValue]];
//    self.jfLabel.text = [NSString stringWithFormat:@"%.2f", [info[@"main_value"] doubleValue]];
//    self.jfTitleLabel.text = [NSString stringWithFormat:@"%@", info[@"main_label"]];
//    self.rightLabel.text = [NSString stringWithFormat:@"%.2f", [info[@"other_value"] doubleValue]];
//    self.rightTitleLabel.text = [NSString stringWithFormat:@"%@", info[@"other_label"]];
}

- (void)configUI {
    [self addSubview:self.bgImgV];
    [self.bgImgV addSubview:self.icon];
    [self.bgImgV addSubview:self.titleLabel];
    [self.bgImgV addSubview:self.moneyLabel];
}

#pragma mark lazy
- (UIImageView *)bgImgV {
    if (!_bgImgV) {
        _bgImgV = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 154)];
    }
    return _bgImgV;
}

- (UIImageView *)icon {
    if (!_icon) {
        _icon = [[UIImageView alloc]initWithFrame:CGRectMake(40, 40, 16, 16)];
    }
    return _icon;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 40, 200, 16)];
        _titleLabel.text = @"";
        _titleLabel.textColor = [UIColor appWhiteLabelColor];
        _titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _titleLabel;
}

- (UILabel *)moneyLabel {
    if (!_moneyLabel) {
        _moneyLabel = [[UILabel alloc]initWithFrame:CGRectMake(40, 60, 200, 50)];
        _moneyLabel.text = @"";
        _moneyLabel.textColor = [UIColor appWhiteLabelColor];
        _moneyLabel.font = [UIFont boldSystemFontOfSize:36];
    }
    return _moneyLabel;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
